package net.chrisrichardson.ec2deployer.applications

import net.chrisrichardson.ec2deployer.core.AWSProperties
import groovy.mock.interceptor.MockFor
import net.chrisrichardson.ec2deployer.core.S3Synchronizer


class WarUploadTest extends GroovyTestCase {

    public void testUpload() {
        AWSProperties awsProperties = new AWSProperties(new Properties())
        def explodedWarPath = 'target/ptrack'
        def webApp = new WebApp(explodedWarPath, "ptrack")

        def mockForS3Synchronizer = new MockFor(S3Synchronizer.class)

        mockForS3Synchronizer.demand.uploadToS3 {wars, bucketPrefix, bucketName ->
            assertEquals "fooBar", bucketPrefix
            assertEquals([explodedWarPath], wars)
            assertEquals "ptrack-tmp-war", bucketName
        }

        mockForS3Synchronizer.use {
            webApp.uploadToS3(awsProperties, "fooBar")
        }
    }

}